package library.and.xps.com.step.util;

import com.jude.utils.JUtils;
import com.orhanobut.logger.*;
import com.orhanobut.logger.Logger;
import com.squareup.okhttp.Request;

import java.util.ArrayList;
import java.util.List;

import library.and.xps.com.step.App;
import library.and.xps.com.step.m.model.AlltodayTeamactivity;
import library.and.xps.com.step.m.netapi.OkHttpClientUtils;
import library.and.xps.com.step.net.ResponceWrapper;

import static library.and.xps.com.step.URLConstants.TEAMACTIVE.UPDATEUSERACTIVE;


public class UploadStep {
    private static final UploadStep ourInstance = new UploadStep();

    public static UploadStep getInstance() {
        return ourInstance;
    }

    private UploadStep() {

    }

    /**
     * @param ads  所有待更新的活动ID
     * @param step 当前步数
     */
    public  void upload(String userId, List<AlltodayTeamactivity.ListBean> ads, String step) {
        String url = UPDATEUSERACTIVE + "?userid=" + userId + "&result=" + step;
        for (AlltodayTeamactivity.ListBean is : ads) {
            OkHttpClientUtils.getDataAsync(App.getInstance().getApplicationContext(), url + "&activityid=" + is.getActivityid(), new RequestCallback() {
                @Override
                public void onFailure(Request request, Exception e) {
                    e.printStackTrace();
                }

                @Override
                public void onResponse(ResponceWrapper response) {
                    if (HttpResponsHelper.SuccessResponce(response)) {
                        Logger.d(response.getBody());
                    }
                }

                @Override
                public void onStart() {

                }
            }, "");
            com.orhanobut.logger.Logger.d("正在更新活动步数");
        }
    }
}
